﻿using UnityEngine;
using System.Collections;

public class Loading_View : ViewUI {
	NGUITweenValue m_Slider;
	UISlider _preload;
	public override void Open(){
		_preload = GetObj().GetGameObject("Slider").GetComponent<UISlider>();
		m_Slider = GetObj().GetGameObject("Slider").GetComponent<NGUITweenValue>();
		m_Slider.SetValueNow = 0;
		m_Slider.UseLerp = false;
		m_Slider.SetUpdateSpeed = 1f;
		m_Slider.TargetValue = 0;
		m_Slider.UseInt = false;
		m_Slider.OnValueChange += M_Slider_OnValueChange;
	}

	void M_Slider_OnValueChange (float value)
	{
		_preload.value = value;
	}	
	public void AddLoadValue(float f){
		m_Slider.TargetValue = m_Slider.TargetValue + f;
	}
	public void SetValue(float f){
		m_Slider.TargetValue = f;
	}
	public float GetSliderValue(){
		return m_Slider.Value;
	}

	public void ControlCallClose(){
		base.OnClose<Loading_View>();
	}
	void Update(){
		if (m_Slider.Value >= 0.99f) {
			base.OnClose<Loading_View>();
		}
	}
}
